package org.example.design.iterator;

import org.example.design.iterator.group.Employee;
import org.example.design.iterator.group.GroupStructure;
import org.example.design.iterator.group.Link;
import org.example.design.iterator.lang.Iterator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @Classname Test
 * @Description 难度 理解树结构深度遍历思想
 * @Date 2020/11/10 11:07 上午
 * @Created by xiangjd
 */
public class Test {
    private  Logger logger = LoggerFactory.getLogger(Test.class);


    @org.junit.Test
    public void test() {
        //数据填充
        GroupStructure groupStructure = new GroupStructure("1", "骑士风");

        //加入雇员
        groupStructure.add(new Employee("2", "花花", "二级部门"));
        groupStructure.add(new Employee("3", "豆包", "二级部门"));
        groupStructure.add(new Employee("4", "蹦蹦", "三级部门"));
        groupStructure.add(new Employee("5", "大烧", "三级部门"));
        groupStructure.add(new Employee("6", "虎哥", "四级部门"));
        groupStructure.add(new Employee("7", "玲姐", "四级部门"));
        groupStructure.add(new Employee("8", "秋雅", "四级部门"));

        //加入组织关系 1->(1,2) 2->(4,5)
        groupStructure.addLink("1", new Link("1", "2"));
        groupStructure.addLink("1", new Link("1", "3"));
        groupStructure.addLink("2", new Link("2", "4"));
        groupStructure.addLink("2", new Link("2", "5"));
        groupStructure.addLink("5", new Link("5", "6"));
        groupStructure.addLink("5", new Link("5", "7"));
        groupStructure.addLink("5", new Link("5", "8"));

        Iterator<Employee> iterator = groupStructure.iterator();

        while (iterator.hasNext()) {
            Employee employee = iterator.next();
            logger.info("{},雇员id:{},雇员姓名:{}", employee.getDesc(), employee.getUid(), employee.getName());
        }
    }

}
